<form id="ajaxForm" action="<{:U('Mentors/comment')}>" method="post" class="form-validata">
	<div class="form-group">
		<label for="title">Star rating</label>
		<div class="star" id="star">
			<?php 
				if($comment){
					for($i=0;$i<$comment['star'];$i++){
						echo '<i class="fa fa-star"></i>';
					}
					for($i=5-$comment['star'];$i>0;$i--){
						echo '<i class="fa fa-star-o"></i>';
					}
				}else{
			?>
			<i class="fa fa-star"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i>
			<?php } ?>
		</div>
		<input id="starVal" name="star" type="hidden" value="1"/>
	</div>
	<div class="form-group">
		<label for="content"><{:L('_content')}></label>
		<textarea id="content" name="content" class="form-control" rows="5" required maxlength=500  placeholder="Please enter evaluation content"><{$comment['content']}></textarea>
	</div>
	<input name="toID" type="hidden" value="<{$list.userid}>"/>
	<input name="toName" type="hidden" value="<{$list.nickname}>"/>
	<input name="toFace" type="hidden" value="<{$list.face}>"/>
	<div class="form-group" style="text-align: right;"><button id="myBtn" type="submit" class="btn btn-primary"><{:L('_submit')}></button></div>
</form>
<script type="text/javascript">
var oStar = document.getElementById("star");
var aLi = oStar.getElementsByTagName("i");
var i = iScore = iStar = <?php if($comment['star']>0){echo $comment['star']; }else{echo 1;} ?>;
for (i = 1; i <= aLi.length; i++){
	aLi[i - 1].index = i;
	//鼠标移过显示分数
	aLi[i - 1].onmouseover = function (){
		fnPoint(this.index);
	}
	//鼠标离开后恢复上次评分
	aLi[i - 1].onmouseout = function (){
		fnPoint();
	};
	//点击后进行评分处理
	aLi[i - 1].onclick = function (){
		iStar = this.index;
		$("#starVal").val(iStar);
	}
}

//评分处理
function fnPoint(iArg){
	//分数赋值
	iScore = iArg || iStar;
	for (i = 0; i < aLi.length; i++){
		aLi[i].className = i < iScore ? "fa fa-star" : "fa fa-star-o";
	} 	
}
</script>